package bullsora.kindlerss.controllers;

import com.bullsora.kindlerss.business.SubscriptionsService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author sorin.buliarca
 */
@Controller
public class SubscriptionsController {

  private static final Log LOG = LogFactory.getLog(SubscriptionsController.class);

  private static final String EMPTY_VIEW_NAME = "empty";

  private SubscriptionsService subscriptionsService;

  @RequestMapping(value = "/subscriptions/scheduleSend", method = RequestMethod.GET)
  public String scheduleSubscriptions() {
    subscriptionsService.scheduleSubscriptionsSend();
    return EMPTY_VIEW_NAME;
  }

  @RequestMapping(value = "/subscriptions/{subscriptionId}/sendNewEntries")
  public String sendNewEntries(@PathVariable("subscriptionId") Long subscriptionId) {
    subscriptionsService.sendNewEntries(subscriptionId);
    return EMPTY_VIEW_NAME;
  }

  public SubscriptionsService getSubscriptionsService() {
    return subscriptionsService;
  }

  public void setSubscriptionsService(SubscriptionsService subscriptionsService) {
    this.subscriptionsService = subscriptionsService;
  }
}
